<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script src="./lib/axios.js"></script>
    <script>
      async function getBook() {
        // 代码的健壮性
        try {
          const res = await axios({
            url: "http://ajax-api.itheima.net/api/books/15",
          });
        } catch (err) {
          console.dir(err);
          alert(err.response.data.message);
        }
        // 错误被捕获不影响下面代码的执行
        console.log(1);
      }

      getBook();
    </script>
  </body>
</html>
